<?php
/**
 * Slipstream :: Highly adaptive dependency injection framework
 * Copyright 2010-2011 Ian Unruh (Xerof3ar)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
namespace Slipstream\Infrastructure\Context\Type;
use Slipstream\Configuration\ContextInterface;

/**
 * Represents an attempt to resolve a context's type
 *
 * @author Ian Unruh (Xerof3ar) <ianunruh@gmail.com>
 * @since Class avaliable since release 1.0
 */
class ResolutionContext
{
	/**
	 * @var ContextInterface
	 */
	protected $context;
	
	/**
	 * @var string
	 */
	protected $resolvedType;
	
	/**
	 * @var ResolutionResult
	 */
	protected $result;
	
	/**
	 * Class constructor
	 *
	 * @param ContextInterface $context
	 * @return void
	 */
	public function __construct(ContextInterface $context)
	{
		$this->context = $context;
		$this->result = ResolutionResult::NotResolved();
	}
	
	/**
	 * Returns the context being resolved
	 * @return ContextInterface
	 */
	public function getContext()
	{
		return $this->context;
	}
	
	/**
	 * Sets the context being resolved
	 *
	 * @param ContextInterface $context
	 * @return void
	 */
	public function setContext(ContextInterface $context)
	{
		$this->context = $context;
	}
	
	/**
	 * Returns the identifier of the context being resolve
	 * @return string
	 */
	public function getIdentifier()
	{
		return $this->context->getIdentifier();
	}
	
	/**
	 * Returns the class or interface type resolved
	 * @return string
	 */
	public function getResolvedType()
	{
		return $this->resolvedType;
	}
	
	/**
	 * Sets the class or interface type resolved
	 *
	 * @param string $resolvedType
	 * @return void
	 */
	public function setResolvedType($resolvedType)
	{
		$this->resolvedType = $resolvedType;
	}
	
	/**
	 * Returns the result from the last resolver
	 * @return ResolutionResult
	 */
	public function getResult()
	{
		return $this->result;
	}
	
	/**
	 * Sets the result from the last resolver
	 *
	 * @param ResolutionResult $result
	 * @return void
	 */
	public function setResult(ResolutionResult $result)
	{
		$this->result = $result;
	}
}